package com.gxa.clientproduct.service.impl;


import com.gxa.clientproduct.mapper.ClassifyMapper;
import com.gxa.clientproduct.pojo.Classify;
import com.gxa.clientproduct.service.ClassifyService;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: fenglin
 * @Date:2020/11/12 14:37
 * @Version 1.0
 */
@Service("classifyService")
public class ClassifyServiceImpl implements ClassifyService {

    @Resource
    ClassifyMapper classifyMapper;
    @Override
    public int classifyDel(Classify classify) {
        return classifyMapper.delete(classify);
    }

    @Override
    public int classifyAdd(Classify classify) {
        return classifyMapper.insertSelective(classify);
    }

    @Override
    public int classifyUpdate(Classify classify) {
        return classifyMapper.updateByPrimaryKeySelective(classify);
    }

    @Override
    public int classifyState(Classify classify) {

        return classifyMapper.updateByPrimaryKeySelective(classify);
    }

    @Override
    public List<Classify> classifyFindAll() {
        return classifyMapper.selectAll();
    }

    @Override
    public List<Classify> classifyFindState( Boolean State) {
        Classify classify = new Classify();
        Example example = new Example(Classify.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("state",classify.getState().equals(true));

        return classifyMapper.selectByExample(example);
    }
}
